﻿using CnBlogsClient.Database;
using System;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace CnBlogsClient.Global
{
    public class MobileInitializer
    {
        public static bool Initialize()
        {
            //做为IOC容器使用

            //Core Services
            DependencyService.Register<CnBlogsCore.Interface.IClientCredentialsService, CnBlogsCore.Services.ClientCredentialsService>();
            DependencyService.Register<CnBlogsCore.Interface.IKbArticleSrvice, CnBlogsCore.Services.KbArticleService>();
            DependencyService.Register<CnBlogsCore.Interface.INewsService, CnBlogsCore.Services.NewsService>();

            //Client Services
            DependencyService.Register<CnBlogsClient.Interface.IKbArticleService, CnBlogsClient.Services.KbArticleService>();
            DependencyService.Register<CnBlogsClient.Interface.INewsService, CnBlogsClient.Services.NewsService>();

            //Global Objects
            DependencyService.Register<CnBlogsClient.Global.AuthConfig>();
            DependencyService.Register<IDatabase, CnBlogsClient.Database.Database>();

            //Global Object Initialize
            DependencyService.Get<IDatabase>().Initialize();
            DependencyService.Get<CnBlogsClient.Global.AuthConfig>().Initialize();

            return true;
        }

    }
}
